<div class="box_right">
	<h1>对账查询</h1>
	<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
	  <ul class="layui-tab-title">
	    <li <?php if (isset($date1)&&isset($date2)){echo 'class="layui-this"';}elseif (!isset($date1)&&!isset($date2)&&!isset($order_no)&&!isset($time1)&&!isset($time2)){echo 'class="layui-this"';}?> onclick="hide_some(1)">批量订单查询</li>
	    <li <?php if (isset($order_no))echo 'class="layui-this"';?> onclick="hide_some(1)">按订单号查询</li>
	   <!--   <li <?php if (isset($time1)&&isset($time2))echo 'class="layui-this"';?> onclick="hide_some(2)">按班次查询</li> -->
	  </ul>
	  <div class="layui-tab-content" style="height: 100px;width:80%;display:inline-block;" > 
	    <div class="layui-tab-item <?php if (isset($date1)&&isset($date2)){echo "layui-show";}elseif (!isset($date1)&&!isset($date2)&&!isset($order_no)&&!isset($time1)&&!isset($time2)){echo "layui-show";}?>">
	    	<form action="<?php echo base_url().'third/order/index'?>" method="get" id="s_form">
			<input name="su_1" type="hidden" class="" id="su_1" value="0">
			<?php if(!empty($city_id)):?>
				<input name="city_id" type="hidden" value="<?php echo $city_id?>">
			<?php endif?>
			<div class="layui-form-item">
			  <div class="layui-inline">
			    <label class="layui-form-label" style="width: 110px;">交易时间</label>
			    <div class="layui-input-inline" style="width: 200px;">
			    	<input name="date1" type="text" class="layui-input" id="test5" placeholder="年-月-日 时:分:秒" value="<?php if (isset($date1)) echo $date1;?>">
			    </div>
			    <div class="layui-form-mid">到</div>
			    <div class="layui-input-inline" style="width: 200px;">
			    	<input name="date2" type="text" class="layui-input" id="test6" placeholder="年-月-日 时:分:秒" value="<?php if (isset($date2)) echo $date2;?>">
			    </div>
			    <p class="say">单次查询日期的最长跨度为31天</p>
			  </div>
			  <div class="layui-inline">
			     <label class="layui-form-label" style="width: 110px;">油号</label>
			     <div class="layui-input-inline" style="width: 100px;">
			     <select name="gm_id" style="width:100px;height:38px;">
				  <option value="0" <?php if ($gm_id == 0){?>selected <?php }?>>全部</option>
			         <?php foreach ($gm as $val){?>
			         <option value="<?php echo $val->id;?>" <?php if ($val->id == $gm_id){?>selected<?php }?>><?php echo $val->glmodel_name;?></option>
			         <?php }?>
			     </select>
			     </div>
			  </div>
              
              <div class="layui-inline">
			     <label class="layui-form-label" style="width: 110px;">手机号</label>
			     <div class="layui-input-inline" style="width: 100px;">
			     <input type="text" name="contact_name" style="width:100px;height:38px;" value="<?php if (!empty($contact_name)){echo $contact_name; }?>"  />
			     </div>
			  </div>
              
              <div class="layui-inline">
			     <label class="layui-form-label" style="width: 110px;">支付状态</label>
			     <div class="layui-input-inline" style="width: 100px;">
			     <select name="payment_status" style="width:100px;height:38px;">
				  <option value="-1" <?php if ($payment_status ==-1){?>selected<?php }?>>全部</option>
                  <option value="0" <?php if ($payment_status == 0){?>selected<?php }?>>未支付</option>   
			      <option value="1" <?php if ($payment_status == 1){?>selected<?php }?>>已支付</option>   
			     </select>
			     </div>
			  </div>
              
              
			  <div class="layui-form-item" style="display: inline-block;">
			    <div class="layui-input-block" style="margin-left: 0px;">
			      <button class="btn_tj" type="submit" onclick="copyText(1)">查询</button>
			    
			    </div>
			  </div>
			  </div>
			</form>
	    </div>
	    <div class="layui-tab-item <?php if (isset($order_no)){echo "layui-show";}?>">
	    	<form action="<?php echo base_url().'third/order/index'?>" method="get">
	    		<?php if(!empty($city_id)):?>
					<input name="city_id" type="hidden" value="<?php echo $city_id?>">
				<?php endif?>
			  <div class="layui-form-item">
			  <div class="layui-inline">
			    <label class="layui-form-label" style="width: 110px;">订单编号</label>
			    <div class="layui-input-inline" style="width: 200px;">
			    	<input type="text" class="layui-input" name="order_no" value="<?php if (isset($order_no)) echo $order_no;?>">
			    </div>
			  </div>
			  </div>
			  <div class="layui-form-item">
			    <div class="layui-input-block">
			      <button class="btn_tj" type="submit">查询</button>
			     
			    </div>
			  </div>
			</form>
	    </div>
	    <div class="layui-tab-item <?php if (isset($time1)&&isset($time2)){echo "layui-show";}?>">
	    	<form action="<?php echo base_url().'third/order/index'?>" method="get">
			<div class="layui-form-item">
			  <div class="layui-inline">
			    <label class="layui-form-label" style="width: 110px;">时间段</label>
			    <div class="layui-input-inline" style="width: 200px;">
			    	<input name="time1" type="text" class="layui-input" id="test7" placeholder="年-月-日 时:分:秒" value="<?php if (isset($time1)) echo $time1;?>">
			    </div>
			    <div class="layui-form-mid">到</div>
			    <div class="layui-input-inline" style="width: 200px;">
			    	<input name="time2" type="text" class="layui-input" id="test8" placeholder="年-月-日 时:分:秒" value="<?php if (isset($time2)) echo $time2;?>">
			    </div> 
			  </div>
			  </div>
			  <div class="layui-form-item">
			    <div class="layui-input-block">
			      <button class="btn_tj" type="submit">查询</button>
			     
			    </div>
			  </div>
			</form>
	    </div>
	  </div>
	  <div style="width:18%;display:inline-block;">
	       <label>已付订单总数：<?php echo $count_2;?></label><br>
	       <label>已付金额合计：<?php echo $total_money;?></label><br>
	       <label>退款订单：<?php echo $count_1;?></label><br>
	       <label>退款总额：<?php echo $total_money_1;?></label>
		   <label>佣金总额：<?php echo $total_commission;?></label>
	  </div>
	  
	  <div class="order_list" style="padding: 10px;margin-top: 15px;">
	  	<div class="layui-row">   
	  		<div class="layui-col-xs4">
	  			<h2 class="order_list_h">订单列表</h2>
	  		</div>
	  		<div class="layui-col-xs1 layui-col-xs-offset7">
	  			<?php if (isset($result)&&count($result)>0){?>
	  			<a class="btn_get" href="###" onclick="javascript:copyText(3);$('#s_form').submit();">导出</a>
	  			<?php }else{?>
	  			<a class="btn_get" href="#" onclick="show_content()">导出</a>
	  			<?php }?>

	  		</div>
	  	</div>
	  		
		<table class="layui-table" lay-skin="line">
		  <thead>
		    <tr>
		      <th>订单号</th>
              <th>手机号</th>
 
			  <th>下单时间</th>
			  <th>车牌号</th>
			  <th>油枪/商品</th>
			  <th>付款方式</th>
			  <th>加油金额</th>
			 
			  <th>订单状态</th>
			  <th>佣金</th>
		    </tr> 
		  </thead>
		  <tbody>
		    <?php if (isset($result)&&count($result)>0){
					foreach ($result as $app){
			?>
			<tr>
				<td><?php echo $app->order_no;?></td>
                <td><?php echo $app->contact_phone;?></td>
                
				<td><?php echo $app->create_time;?></td>
				<td><?php echo $app->car_card;?></td>
				<td><?php echo $app->oilgun_name.'/'.$app->glmodel_name;?></td>
				<td><?php
                    if($app->payment_id == 2){
                        echo "支付宝支付";
                    }elseif($app->payment_id == 3){
                    	echo "微信公众号支付";
                    }elseif($app->payment_id == 6){
                    	echo "支付宝APP支付";
					}elseif($app->payment_id == 7){
                    	echo "微信APP支付";
					}elseif($app->payment_id == 8){
                    	echo "钱包支付";
					}elseif($app->payment_id == 9){
						echo "小程序支付";
					}
					?>
				</td>
				<td><?php echo $app->machine_price?></td>
				
				
				<td>
				
				
				<?php if($app->status == 7&&$app->payment_status==1){?>
					已退款
					<?php }else{?>
					<?php if($app->payment_status == 1){?>
					已支付
					<?php }else{?>
					未支付
					<?php }}?>
				</td>
				
				<td><?php if(!empty($_SESSION['THIRD_USER_RATE'])&&$app->status!=7&&$app->payment_status==1){ echo round($app->machine_price*$_SESSION['THIRD_USER_RATE'],2);}?></td>
			</tr>
				<?php }
			}else{?>
			<tr>
				<td colspan="15">无数据</td>
			</tr>
			<?php }?>
		  </tbody>
		</table>
	  </div>
	  <div class="col-sm-12" id="page">
		<div class="modal-footer no-margin-top">
			<div class="pull-left record">
				共<?php echo $count;?>条记录
				</div>
            	<?php if (isset($page))echo $page;?>
		</div>
	  </div>
	  
	  
	</div>   
</div>
<script>
//Demo
layui.use(['form','element','laydate'], function(){
  var form = layui.form,
  	element = layui.element,
  	laydate = layui.laydate;

  //时间选择器
  laydate.render({
    elem: '#test5'
    ,type: 'datetime'
  });
    //时间选择器
  laydate.render({
    elem: '#test6'
    ,type: 'datetime'
  }); 
//时间选择器
  laydate.render({
    elem: '#test7'
    ,type: 'datetime'
  });
    //时间选择器
  laydate.render({
    elem: '#test8'
    ,type: 'datetime'
  }); 
  //监听提交
  form.on('submit(formDemo)', function(data){
    layer.msg(JSON.stringify(data.field));
    return false;
  });
});
function show_content(){
    alert("暂无数据！");
}

$(document).ready(function(){
	var type='<?php echo $type;?>';
	hide_some(type);
});
function hide_some(id){
	if(id == 1){
	   $('.order_list').show();
	   $('#page').show();
	   $('#order_list2').hide();
	}else{
		$('.order_list').hide();
		$('#page').hide();
		$('#order_list2').show();
	}
	
}
function copyText(type) {
	$("#su_1").get(0).value = type;
}
</script>

	